Allow the custom widget to actualize on a printer change
authorMarek Kasik <mkasik@redhat.com>
Tue, 21 Apr 2009 11:06:49 +0000 (13:06 +0200)
committerMarek Kasik <mkasik@redhat.com>
Tue, 21 Apr 2009 11:06:49 +0000 (13:06 +0200)
Passes print settings and page setup to the custom widget
through a new "update-custom-widget" signal (#564854).

gtk/gtkmarshalers.list
gtk/gtkprintoperation-unix.c
gtk/gtkprintoperation.c
gtk/gtkprintoperation.h
gtk/gtkprintunixdialog.c

index c932f1d555c73103663d8b35b3903da4d10b221d..3e19a21551a11678b3bf2a67e978f86bda09041d 100644 (file)
@@ -88,6 +88,7 @@ VOID:OBJECT,STRING,STRING
 VOID:OBJECT,UINT
 VOID:OBJECT,UINT,FLAGS
 VOID:OBJECT,STRING
+VOID:OBJECT,OBJECT,OBJECT
 VOID:POINTER
 VOID:POINTER,INT
 VOID:POINTER,BOOLEAN
index 6ec4ebdd8cf76d523cd294021c51621c66caa0cf..bec565c01fcaa4a9bbdf71a246918532f8b2ce72 100644 (file)
@@ -363,6 +363,26 @@ job_status_changed_cb (GtkPrintJob       *job,
 }
 
 
+static void
+printer_changed_cb (GtkPrintUnixDialog *print_dialog, 
+                    GParamSpec         *pspec,
+                    gpointer            user_data)
+{
+  GtkPageSetup             *page_setup;
+  GtkPrintSettings         *print_settings;
+  GtkPrintOperation        *op = user_data;
+  GtkPrintOperationPrivate *priv = op->priv;
+
+  page_setup = gtk_print_unix_dialog_get_page_setup (print_dialog);
+  print_settings = gtk_print_unix_dialog_get_settings (print_dialog);
+
+  g_signal_emit_by_name (op,
+                         "update-custom-widget",
+                         priv->custom_widget,
+                         page_setup,
+                         print_settings);
+}
+
 static GtkWidget *
 get_print_dialog (GtkPrintOperation *op,
                   GtkWindow         *parent)
@@ -409,6 +429,8 @@ get_print_dialog (GtkPrintOperation *op,
       
       gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (pd),
                                            priv->custom_widget, label);
+
+      g_signal_connect (pd, "notify::selected-printer", (GCallback) printer_changed_cb, op);
     }
   
   return pd;
index 05b8b9e4a7f5d44aa96fc4196391aea3a5bdab9c..424054601ffc8b4443f6a13aec398f4ba2d97cfc 100644 (file)
@@ -48,6 +48,7 @@ enum
   CREATE_CUSTOM_WIDGET,
   CUSTOM_WIDGET_APPLY,
   PREVIEW,
+  UPDATE_CUSTOM_WIDGET,
   LAST_SIGNAL
 };
 
@@ -819,13 +820,35 @@ gtk_print_operation_class_init (GtkPrintOperationClass *class)
                  _gtk_marshal_OBJECT__VOID,
                  G_TYPE_OBJECT, 0);
 
+  /**
+   * GtkPrintOperation::update-custom-widget:
+   * @operation: the #GtkPrintOperation on which the signal was emitted
+   * @widget: the custom widget added in create-custom-widget
+   * @setup: actual page setup
+   * @settings: actual print settings
+   *
+   * Emmited after change of selected printer. The actual page setup and
+   * print settings are passed to the custom widget, which can actualize
+   * itself according to this change. 
+   *
+   * Since: 2.18
+   */
+  signals[UPDATE_CUSTOM_WIDGET] =
+    g_signal_new (I_("update-custom-widget"),
+                 G_TYPE_FROM_CLASS (class),
+                 G_SIGNAL_RUN_LAST,
+                 G_STRUCT_OFFSET (GtkPrintOperationClass, update_custom_widget),
+                 NULL, NULL,
+                 _gtk_marshal_VOID__OBJECT_OBJECT_OBJECT,
+                 G_TYPE_NONE, 3, GTK_TYPE_WIDGET, GTK_TYPE_PAGE_SETUP, GTK_TYPE_PRINT_SETTINGS);
+
   /**
    * GtkPrintOperation::custom-widget-apply:
    * @operation: the #GtkPrintOperation on which the signal was emitted
    * @widget: the custom widget added in create-custom-widget
    *
    * Emitted right before #GtkPrintOperation::begin-print if you added
-   * a custom widget in the #GtkPrintOperation:;create-custom-widget handler. 
+   * a custom widget in the #GtkPrintOperation::create-custom-widget handler. 
    * When you get this signal you should read the information from the 
    * custom widgets, as the widgets are not guaraneed to be around at a 
    * later time.
index a3f04109434f615b3c70cdc14bc50af5abf61868..af46332fcf7cc268caa7e25b55f2e084a9d1dade 100644 (file)
@@ -105,13 +105,18 @@ struct _GtkPrintOperationClass
 
   GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
   void       (*custom_widget_apply)  (GtkPrintOperation *operation,
-                                     GtkWidget *widget);
+                                     GtkWidget         *widget);
 
   gboolean (*preview)       (GtkPrintOperation        *operation,
                              GtkPrintOperationPreview *preview,
                              GtkPrintContext          *context,
                              GtkWindow                *parent);
 
+  void     (*update_custom_widget) (GtkPrintOperation *operation,
+                                    GtkWidget         *widget,
+                                    GtkPageSetup      *setup,
+                                    GtkPrintSettings  *settings);
+
   /* Padding for future expansion */
   void (*_gtk_reserved1) (void);
   void (*_gtk_reserved2) (void);
@@ -119,7 +124,6 @@ struct _GtkPrintOperationClass
   void (*_gtk_reserved4) (void);
   void (*_gtk_reserved5) (void);
   void (*_gtk_reserved6) (void);
-  void (*_gtk_reserved7) (void);
 };
 
 #define GTK_PRINT_ERROR gtk_print_error_quark ()
index 72520f82a72d3ebe53fdba63de5d1605d058f143..9f4cd6123a566827ca60e0e3191d69a97413b5b3 100644 (file)
@@ -1552,6 +1552,8 @@ selected_printer_changed (GtkTreeSelection   *selection,
 
   update_dialog_from_settings (dialog);
   update_dialog_from_capabilities (dialog);
+
+  g_object_notify ( G_OBJECT(dialog), "selected-printer");
 }
 
 static void